package j.framework.tags.easyui;

import javax.servlet.jsp.JspException;
import java.util.Map;

/**
 * 多行文本输入框
 * Created by junhai on 2015/1/18.
 */
public class TextareaTag extends TextBoxTag {

    private static final int LINE_HEIGHT = 18;

    /**
     * 指定行数，不是精准的行数，按每行18个像素相加
     */
    private Integer rows;

    @Override
    public void writeEasyuiDataOptions(Map<String, Object> dataOptions) throws JspException {
        super.writeEasyuiDataOptions(dataOptions);
        dataOptions.put("multiline",true);
        if(rows!=null && rows>0){
            dataOptions.put("height",rows*LINE_HEIGHT);
        }else{
            //没有指定高度，则采用默认的2行
            dataOptions.put("height",2*LINE_HEIGHT);
        }
    }

    public void setRows(Integer rows) {
        this.rows = rows;
    }
}
